import Vue from 'vue'
import Vuex from 'vuex'
import defaultCity from './state'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    city: defaultCity.city
  },
  actions: {
    changeCityName: function (ctx, city) {
      ctx.commit('changeCityName', city)
    }
  },
  mutations: {
    changeCityName: function (state, city) {
      state.city = city
      localStorage.city = city
    }
  }
})
// dispatch 分发 commit 提交 mutate 改变 render 渲染四步
